package ch.hoth.java.joocal;

import java.util.Date;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import com.google.gdata.data.extensions.EventEntry;

import ch.hoth.java.joocal.ui.MainDialog;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		GoogleUser david = GoogleUserFactory.getUser("dagomox");
		Calendar calendar = new Calendar(david);
		
		EventEntry ge1 = GEventsFactory.getEvent();
		EventEntry ge2 = GEventsFactory.getEvent();
		EventEntry ge3 = GEventsFactory.getEvent();
		EventEntry ge4 = GEventsFactory.getEvent();
		
		Event2 e1 = new Event2(ge1);
		Event2 e2 = new Event2(ge2);
		Event2 e3 = new Event2(ge3);
		Event2 e4 = new Event2(ge4);
		
		calendar.addEvent(e1);
		calendar.addEvent(e2);
		calendar.addEvent(e3);
		calendar.addEvent(e4);
		
		CalendarController controller = new CalendarController();
		controller.addCalendar(calendar);
		
		boolean gui = true;
		for (int i=0; i<args.length; i++){
			if (args[i].equals("-nogui")){
				gui = false;
			}
		}
		
		if (gui){
			MainDialog dialog = new MainDialog(controller);
			dialog.open();
			Shell shell = dialog.getShell();
			while (!shell.isDisposed())
	        {
	            if (!Display.getCurrent().readAndDispatch())
	            {
	                Display.getCurrent().sleep();
	            }
	        }
	        Display.getCurrent().dispose();
			
		}
		else{
			// operation
		}

	}

}
